<!DOCTYPE html><html><head><title>Ext.form.field.VTypes | Ext JS 4.0 Documentation</title><script type="text/javascript" src="../ext-all.js"></script><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../scrollbars.css" type="text/css"><link rel="stylesheet" href="../docs.css" type="text/css"><link id="styleCss" rel="stylesheet" href="../style.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script><link rel="stylesheet" href="../prettify.css" type="text/css"><!-- link(rel: 'stylesheet', href: req.baseURL + '/css/ext4.css', type: 'text/css')--><link rel="shortcut icon" type="image/ico" href="../favicon.ico"><!--[if IE]>
<style type="text/css">.head-band { display: none; }
.header { border: 0; top: 0; left: 0px; background: url(../header.gif) repeat-x; }
.doc-tab .members .member a.more { background-color: #efefef; }
</style><link rel="stylesheet" href="/new/css/ie.css" type="text/css"><![endif]-->
</head><body id="ext-body" class="iScroll"><div id="notice" class="notice">For up to date documentation and features, visit 
<a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a></div><div class="wrapper"><div class="head-band"></div><div class="header"><h2><a href="../index.html">Sencha Documentation</a></h2></div><div id="search"><form><input type="text" placeholder="Search" id="search-field" autocomplete="off" name="q"></form><div id="search-box"></div></div><div id="treePanel"></div><div id="container"><script type="text/javascript">

    req = {
        liveURL: '.',
        standAloneMode: true,
        origDocClass: 'Ext.form.field.VTypes',
        docClass: 'Ext.form.field.VTypes',
        docReq: 'Ext.form.field.VTypes',
        version: '4.0',
        baseURL: '.',
        baseDocURL: '.',
        baseProdURL: '.'
    };

    clsInfo = {};



</script>

<script type="text/javascript" src="../search.js"></script>
<!--script type="text/javascript" src="/new/javascripts/app/examples.js"></script-->
<script type="text/javascript" src="../class_tree.js"></script>
<script type="text/javascript" src="../class_doc.js"></script>
<script type="text/javascript">
    req.source = 'VTypes.html#Ext-form.field.VTypes';
    clsInfo = {"methods":["alpha","alphanum","email","url"],"cfgs":[],"properties":["alphaMask","alphaText","alphanumMask","alphanumText","emailMask","emailText","urlText"],"events":[],"subclasses":[]};
    Ext.onReady(function() {
        Ext.create('Docs.classPanel');
    });
</script><div id="top-block" class="top-block"><h1 id="clsTitle" class="cls"><a href="../source/VTypes.html#Ext-form.field.VTypes" target="_blank">Ext.form.field.VTypes</a></h1></div><div id="docContent"><div id="doc-overview-content"><div class="lft"><p>This is a singleton object which contains a set of commonly used field validation functions.
The validations provided are basic and intended to be easily customizable and extended.</p>


<p>To add custom VTypes specify the <code><a href="Ext.form.field.Text.html#vtype" rel="Ext.form.field.Text#vtype" class="docClass">vtype</a></code> validation
test function, and optionally specify any corresponding error text to display and any keystroke
filtering mask to apply. For example:</p>


<pre class="prettyprint"><code>// custom Vtype for vtype:'time'
var timeTest = /^([1-9]|1[0-9]):([0-5][0-9])(\s[a|p]m)$/i;
Ext.apply(Ext.form.field.VTypes, {
    //  vtype validation function
    time: function(val, field) {
        return timeTest.test(val);
    },
    // vtype Text property: The error text to display when the validation function returns false
    timeText: 'Not a valid time.  Must be in the format "12:34 PM".',
    // vtype Mask property: The keystroke filter mask
    timeMask: /[\d\s:amp]/i
});
</code></pre>


<p>Another example:</p>

<pre class="prettyprint"><code>// custom Vtype for vtype:'IPAddress'
Ext.apply(Ext.form.field.VTypes, {
    IPAddress:  function(v) {
        return /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(v);
    },
    IPAddressText: 'Must be a numeric IP address',
    IPAddressMask: /[\d\.]/i
});
</code></pre>

<div class="members"><div class="m-properties"><a name="properties"></a><div class="definedBy">Defined By</div><h3 class="prp p">Properties</h3><div id="property-alphaMask" class="member f ni"><a href="Ext.form.field.VTypes.html#property-alphaMask" rel="property-alphaMask" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphaMask" class="viewSource">view source</a></div><a name="alphaMask"></a><a name="property-alphaMask"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphaMask" class="cls expand">alphaMask</a><span> : RegExp</span></div><div class="description"><div class="short"><p>The keystroke filter mask to be applied on alpha input.  Defaults to:
<tt>/[a-z_]/i</tt></p>
</div><div class="long"><p>The keystroke filter mask to be applied on alpha input.  Defaults to:
<tt>/[a-z_]/i</tt></p>
</div></div></div><div id="property-alphaText" class="member ni"><a href="Ext.form.field.VTypes.html#property-alphaText" rel="property-alphaText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphaText" class="viewSource">view source</a></div><a name="alphaText"></a><a name="property-alphaText"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphaText" class="cls expand">alphaText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the alpha validation function returns false.  Defaults to:
'This field should only con...</div><div class="long"><p>The error text to display when the alpha validation function returns false.  Defaults to:
<tt>'This field should only contain letters and _'</tt></p>
</div></div></div><div id="property-alphanumMask" class="member ni"><a href="Ext.form.field.VTypes.html#property-alphanumMask" rel="property-alphanumMask" class="expand more"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphanumMask" class="viewSource">view source</a></div><a name="alphanumMask"></a><a name="property-alphanumMask"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphanumMask" class="cls expand">alphanumMask</a><span> : RegExp</span></div><div class="description"><div class="short"><p>The keystroke filter mask to be applied on alphanumeric input.  Defaults to:
<tt>/[a-z0-9_]/i</tt></p>
</div><div class="long"><p>The keystroke filter mask to be applied on alphanumeric input.  Defaults to:
<tt>/[a-z0-9_]/i</tt></p>
</div></div></div><div id="property-alphanumText" class="member ni"><a href="Ext.form.field.VTypes.html#property-alphanumText" rel="property-alphanumText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-alphanumText" class="viewSource">view source</a></div><a name="alphanumText"></a><a name="property-alphanumText"></a><a href="Ext.form.field.VTypes.html#" rel="property-alphanumText" class="cls expand">alphanumText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the alphanumeric validation function returns false.  Defaults to:
'This field should o...</div><div class="long"><p>The error text to display when the alphanumeric validation function returns false.  Defaults to:
<tt>'This field should only contain letters, numbers and _'</tt></p>
</div></div></div><div id="property-emailMask" class="member ni"><a href="Ext.form.field.VTypes.html#property-emailMask" rel="property-emailMask" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-emailMask" class="viewSource">view source</a></div><a name="emailMask"></a><a name="property-emailMask"></a><a href="Ext.form.field.VTypes.html#" rel="property-emailMask" class="cls expand">emailMask</a><span> : RegExp</span></div><div class="description"><div class="short">The keystroke filter mask to be applied on email input.  See the email method for
information about more complex emai...</div><div class="long"><p>The keystroke filter mask to be applied on email input.  See the <a href="Ext.form.field.VTypes.html#email" rel="Ext.form.field.VTypes#email" class="docClass">email</a> method for
information about more complex email validation. Defaults to:
<tt>/[a-z0-9_.-@]/i</tt></p>
</div></div></div><div id="property-emailText" class="member ni"><a href="Ext.form.field.VTypes.html#property-emailText" rel="property-emailText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-emailText" class="viewSource">view source</a></div><a name="emailText"></a><a name="property-emailText"></a><a href="Ext.form.field.VTypes.html#" rel="property-emailText" class="cls expand">emailText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the email validation function returns false.  Defaults to:
'This field should be an e-...</div><div class="long"><p>The error text to display when the email validation function returns false.  Defaults to:
<tt>'This field should be an e-mail address in the format "user@example.com"'</tt></p>
</div></div></div><div id="property-urlText" class="member ni"><a href="Ext.form.field.VTypes.html#property-urlText" rel="property-urlText" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-property-urlText" class="viewSource">view source</a></div><a name="urlText"></a><a name="property-urlText"></a><a href="Ext.form.field.VTypes.html#" rel="property-urlText" class="cls expand">urlText</a><span> : String</span></div><div class="description"><div class="short">The error text to display when the url validation function returns false.  Defaults to:
'This field should be a URL i...</div><div class="long"><p>The error text to display when the url validation function returns false.  Defaults to:
<tt>'This field should be a URL in the format "http:/'+'/www.example.com"'</tt></p>
</div></div></div></div><div class="m-methods"><a name="methods"></a><div class="definedBy">Defined By</div><h3 class="mth p">Methods</h3><div id="method-alpha" class="member f ni"><a href="Ext.form.field.VTypes.html#method-alpha" rel="method-alpha" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-alpha" class="viewSource">view source</a></div><a name="alpha"></a><a name="method-alpha"></a><a href="Ext.form.field.VTypes.html#" rel="method-alpha" class="cls expand">alpha</a>(
<span class="pre">String value</span>)
 : Boolean</div><div class="description"><div class="short"><p>The function used to validate alpha values</p>
</div><div class="long"><p>The function used to validate alpha values</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The value</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
</li></ul></div></div></div><div id="method-alphanum" class="member ni"><a href="Ext.form.field.VTypes.html#method-alphanum" rel="method-alphanum" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-alphanum" class="viewSource">view source</a></div><a name="alphanum"></a><a name="method-alphanum"></a><a href="Ext.form.field.VTypes.html#" rel="method-alphanum" class="cls expand">alphanum</a>(
<span class="pre">String value</span>)
 : Boolean</div><div class="description"><div class="short"><p>The function used to validate alphanumeric values</p>
</div><div class="long"><p>The function used to validate alphanumeric values</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The value</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
</li></ul></div></div></div><div id="method-email" class="member ni"><a href="Ext.form.field.VTypes.html#method-email" rel="method-email" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-email" class="viewSource">view source</a></div><a name="email"></a><a name="method-email"></a><a href="Ext.form.field.VTypes.html#" rel="method-email" class="cls expand">email</a>(
<span class="pre">String value</span>)
 : Boolean</div><div class="description"><div class="short">The function used to validate email addresses.  Note that this is a very basic validation -- complete
validation per ...</div><div class="long"><p>The function used to validate email addresses.  Note that this is a very basic validation -- complete
validation per the email RFC specifications is very complex and beyond the scope of this class, although
this function can be overridden if a more comprehensive validation scheme is desired.  See the validation
section of the <a href="http://en.wikipedia.org/wiki/E-mail_address">Wikipedia article on email addresses</a>
for additional information.  This implementation is intended to validate the following emails:<tt>
'barney@example.de', 'barney.rubble@example.com', 'barney-rubble@example.coop', 'barney+rubble@example.com'
</tt>.</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The email address</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
</li></ul></div></div></div><div id="method-url" class="member ni"><a href="Ext.form.field.VTypes.html#method-url" rel="method-url" class="expand more ar"><span>&nbsp;</span></a><div class="title"><div class="meta"><a href="Ext.form.field.VTypes.html" class="definedIn docClass">Ext.form.field.VTypes</a><br/><a href="../source/VTypes.html#Ext-form.field.VTypes-method-url" class="viewSource">view source</a></div><a name="url"></a><a name="method-url"></a><a href="Ext.form.field.VTypes.html#" rel="method-url" class="cls expand">url</a>(
<span class="pre">String value</span>)
 : Boolean</div><div class="description"><div class="short"><p>The function used to validate URLs</p>
</div><div class="long"><p>The function used to validate URLs</p>
<h3 class="pa">Parameters</h3><ul><li><span class="pre">value</span> : String<div class="sub-desc"><p>The URL</p>
</div></li></ul><h3 class="pa">Returns</h3><ul><li><span class="pre">Boolean</span>&nbsp; &nbsp;<p>true if the RegExp test passed, and false if not.</p>
</li></ul></div></div></div></div></div></div></div><div id="pageContent"></div></div></div></div></body></html>